home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / Miro_Installer.exe / Miro_Downloader.exe / compiled_templates / channel_folder.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-01-10  |  30.4 KB  |  546 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.5)
  3.  
  4. from template import Handle, fillAttr, quoteAndFillAttr, fillStaticTemplate
  5. from StringIO import StringIO
  6. from xhtmltools import urlencode
  7. from templatehelper import quoteattr, escape
  8. from string import Template
  9. import app
  10. import views
  11. import sorts
  12. import indexes
  13. import filters
  14. import resources
  15. import gtcache
  16. _ = gtcache.gettext
  17.  
  18. def fillTemplate(domHandler, dtvPlatform, eventCookie, bodyTagExtra, *args, **kargs):
  19.     global searchTerm, allItemsMode, showDownloads, showNewItems, showWatchableItems, showNewItems, allItemsMode
  20.     folder = views.channelFolders.getObjectByID(int(kargs['id']))
  21.     filters.switchNewItemsChannel(folder)
  22.     sorts.switchUnwatchedFirstChannel(folder)
  23.     
  24.     def showDownloadsFilter(x):
  25.         return showDownloads
  26.  
  27.     
  28.     def showWatchableFilter(x):
  29.         return showWatchableItems
  30.  
  31.     
  32.     def showNewFilter(x):
  33.         isNew = filters.newItems(x)
  34.         if not showNewItems and allItemsMode:
  35.             pass
  36.         return isNew
  37.  
  38.     
  39.     def updateSearchString(newSearch):
  40.         global searchTerm, searchTerm
  41.         if len(newSearch) == 0:
  42.             searchTerm = None
  43.         else:
  44.             searchTerm = newSearch
  45.         allItems.recomputeFilters()
  46.  
  47.     
  48.     def toggleDownloadsView(handle):
  49.         global showDownloads
  50.         showDownloads = not showDownloads
  51.         allDownloadingItems.recomputeFilter(downloadingItems)
  52.         handle.forceUpdate()
  53.  
  54.     
  55.     def toggleWatchableView(handle):
  56.         global showWatchableItems
  57.         showWatchableItems = not showWatchableItems
  58.         allWatchableItems.recomputeFilter(watchableItems)
  59.         handle.forceUpdate()
  60.  
  61.     
  62.     def toggleNewItemsView(handle):
  63.         global showNewItems
  64.         showNewItems = not showNewItems
  65.         matchingItems.recomputeFilter(newItems)
  66.         handle.forceUpdate()
  67.  
  68.     
  69.     def toggleAllItemsMode(handle):
  70.         global allItemsMode
  71.         print 'Toggling all items'
  72.         allItemsMode = not allItemsMode
  73.         matchingItems.recomputeFilter(newItems)
  74.         handle.forceUpdate()
  75.  
  76.     
  77.     def setSortBy(by, which, handle):
  78.         if which == 'main':
  79.             folder.itemSort.setSortBy(by)
  80.             matchingItems.recomputeSort(newItems)
  81.         elif which == 'downloading':
  82.             feed.itemSortDownloading.setSortBy(by)
  83.             allDownloadingItems.recomputeSort(downloadingItems)
  84.         else:
  85.             folder.itemSortWatchable.setSortBy(by)
  86.             allWatchableItems.recomputeSort(watchableItems)
  87.         handle.forceUpdate()
  88.  
  89.     allFeeds = views.feeds.filterWithIndex(indexes.byFolder, folder)
  90.     searchTerm = None
  91.     allItemsMode = False
  92.     showDownloads = False
  93.     showNewItems = True
  94.     showWatchableItems = True
  95.     allItems = views.items.filterWithIndex(indexes.itemsByChannelFolder, folder)
  96.     notDeleted = allItems.filter(filters.notDeleted)
  97.     matchingItems = notDeleted.filter((lambda x: filters.matchingItems(x, searchTerm)))
  98.     newItems = matchingItems.filter(showNewFilter, sortFunc = folder.itemSort.sort, resort = True)
  99.     allDownloadingItems = matchingItems.filter(filters.downloadingOrPausedItems)
  100.     downloadingItems = allDownloadingItems.filter(showDownloadsFilter, sortFunc = folder.itemSortDownloading.sort, resort = True)
  101.     allWatchableItems = matchingItems.filter(filters.watchableItems)
  102.     watchableItems = allWatchableItems.filter(showWatchableFilter, sortFunc = folder.itemSortWatchable.sort, resort = True)
  103.     thisFolderView = (views.channelFolders.filter,)((lambda x: x is folder))
  104.     childrenView = views.feeds.filterWithIndex(indexes.byFolder, folder)
  105.     thisFeedView = thisFolderView
  106.     feed = None
  107.     itemSort = folder.itemSort
  108.     itemSortDownloading = folder.itemSortDownloading
  109.     itemSortWatchable = folder.itemSortWatchable
  110.     
  111.     def allItemsHaveState(view, state):
  112.         for item in view:
  113.             if item.getState() != state:
  114.                 return False
  115.                 continue
  116.         
  117.         return True
  118.  
  119.     
  120.     def allItemsPaused(view):
  121.         return allItemsHaveState(view, 'paused')
  122.  
  123.     
  124.     def allItemsDownloading(view):
  125.         return allItemsHaveState(view, 'downloading')
  126.  
  127.     if not len(watchableItems) == 0:
  128.         pass
  129.     showNewItems = len(newItems) > 0
  130.     if len(newItems) == 0:
  131.         allItemsMode = True
  132.         matchingItems.recomputeFilter(newItems)
  133.     
  134.     for None in allFeeds:
  135.         feed = None
  136.     
  137.     isFolder = True
  138.     
  139.     def _execOnUnload():
  140.         matchingItems.unlink()
  141.         thisFolderView.unlink()
  142.         notDeleted.unlink()
  143.         allItems.unlink()
  144.         for feed in allFeeds:
  145.             if feed.idExists():
  146.                 feed.markAsViewed()
  147.                 continue
  148.         
  149.  
  150.     localvars = locals()
  151.     localvars.update(globals())
  152.     handle = Handle(domHandler, localvars, onUnlink = _execOnUnload)
  153.     
  154.     def up_0_handle(viewName, view, tid):
  155.         out = StringIO()
  156.         out.write(u'<div id="')
  157.         out.write(quoteattr(tid))
  158.         out.write(u'">\n        <h1 id="main-title">')
  159.         out.write(escape(folder.getTitle()))
  160.         out.write(u'</h1>\n    </div>')
  161.         out.seek(0)
  162.         return out
  163.  
  164.     handle.addUpdate('tmplcomp12122406', 'nextSibling', thisFolderView, up_0_handle, u'thisFolderView')
  165.     
  166.     def up_1_handle(viewName, view, tid):
  167.         out = StringIO()
  168.         out.write(u'<div id="')
  169.         out.write(quoteattr(tid))
  170.         out.write(u'">\n')
  171.         if not not (childrenView.len() == 0):
  172.             out.write(u'<div>\n    <div class="channel-blank">\n    <div class="channel-message">')
  173.             out.write(_(u'Empty Channel Folder'))
  174.             out.write(u'</div>\n    <div class="channel-message small">')
  175.             out.write(_(u'Drag channels to this folder to add them.'))
  176.             out.write(u'</div>\n    </div>\n</div>')
  177.         
  178.         out.write(u'\n</div>')
  179.         out.seek(0)
  180.         return out
  181.  
  182.     handle.addUpdate('tmplcomp05112787', 'nextSibling', childrenView, up_1_handle, u'childrenView')
  183.     localvars = locals()
  184.     localvars.update(globals())
  185.     handle_0 = Handle(domHandler, localvars, onUnlink = (lambda : None))
  186.     
  187.     def up_0_handle_0(viewName, view, tid):
  188.         out = StringIO()
  189.         out.write(u'<div id="')
  190.         out.write(quoteattr(tid))
  191.         out.write(u'">\n')
  192.         if not allDownloadingItems.len() == 0:
  193.             out.write(u'<div>\n<div class="main-channelbar downloading-channelbar" onclick="return eventURL(\'action:toggleDownloadsView\');">\n  ')
  194.             if not showDownloads:
  195.                 out.write(u'<div class="triangle"></div>')
  196.             
  197.             out.write(u'\n  ')
  198.             if not not showDownloads:
  199.                 out.write(u'<div class="triangle down"></div>')
  200.             
  201.             out.write(u'\n  <a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:cancelDownloads\', event);">Cancel All</a>\n  ')
  202.             if not allItemsPaused(allDownloadingItems):
  203.                 out.write(u'<a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:pauseDownloads\', event);">Pause All</a>')
  204.             
  205.             out.write(u'\n  ')
  206.             if not allItemsDownloading(allDownloadingItems):
  207.                 out.write(u'<a href="#" class="download-bar-action" onclick="eventURLAndStop(\'action:resumeDownloads\', event);">Resume All</a>')
  208.             
  209.             out.write(u'\n  ')
  210.             if not allDownloadingItems.len() == 1:
  211.                 out.write(u'<span>\n      <span>')
  212.                 out.write(escape(allDownloadingItems.len()))
  213.                 out.write(u'</span> Downloading</span>')
  214.             
  215.             out.write(u'\n   ')
  216.             if not allDownloadingItems.len() != 1:
  217.                 out.write(u'<span>1 Downloading</span>')
  218.             
  219.             out.write(u'\n</div>\n</div>')
  220.         
  221.         out.write(u'\n</div>')
  222.         out.seek(0)
  223.         return out
  224.  
  225.     handle_0.addUpdate('tmplcomp02773866', 'nextSibling', allDownloadingItems, up_0_handle_0, u'allDownloadingItems')
  226.     
  227.     def up_1_handle_0(viewName, view, tid):
  228.         out = StringIO()
  229.         out.write(u'<div class="downloading-sort" id="')
  230.         out.write(quoteattr(tid))
  231.         out.write(u'">\n        ')
  232.         if not downloadingItems.len() == 0:
  233.             out.write(u'<div>\n            ')
  234.             out.write(fillStaticTemplate(u'sort-bar', onlyBody = True, section = 'downloading', itemSort = itemSortDownloading))
  235.             out.write(u'\n        </div>')
  236.         
  237.         out.write(u'\n    </div>')
  238.         out.seek(0)
  239.         return out
  240.  
  241.     handle_0.addUpdate('tmplcomp36590227', 'nextSibling', downloadingItems, up_1_handle_0, u'downloadingItems')
  242.     
  243.     def up_2_handle_0(viewName, view, tid):
  244.         out = StringIO()
  245.         out.write(u'<a href="#" class="main-channelbar available-channelbar" onclick="return eventURL(\'action:toggleNewItemsView\');" id="')
  246.         out.write(quoteattr(tid))
  247.         out.write(u'">\n        ')
  248.         if not showNewItems:
  249.             out.write(u'<div class="triangle"></div>')
  250.         
  251.         out.write(u'\n        ')
  252.         if not not showNewItems:
  253.             out.write(u'<div class="triangle down"></div>')
  254.         
  255.         out.write(u'\n\n        ')
  256.         if not not (not isFolder):
  257.             out.write(u'<div>\n            ')
  258.             if not feed.inlineSearchTerm is not None:
  259.                 out.write(u'<div>\n                <span>')
  260.                 out.write(escape(notDeleted.len()))
  261.                 out.write(u'</span> \n                Items in this Channel\n            </div>')
  262.             
  263.             out.write(u'\n            ')
  264.             if not feed.inlineSearchTerm is None:
  265.                 out.write(u'<div>\n                ')
  266.                 if not not (notDeleted.len() == matchingItems.len()):
  267.                     out.write(u'<div>\n                    All <span>')
  268.                     out.write(escape(matchingItems.len()))
  269.                     out.write(u'</span> \n                    Match This Search\n                </div>')
  270.                 
  271.                 out.write(u'\n                ')
  272.                 if not notDeleted.len() == matchingItems.len():
  273.                     out.write(u'<div>\n                    <span>')
  274.                     out.write(escape(matchingItems.len()))
  275.                     out.write(u'</span> \n                    Match This Search\n                </div>')
  276.                 
  277.                 out.write(u'\n            </div>')
  278.             
  279.             out.write(u'\n        </div>')
  280.         
  281.         out.write(u'\n\n        ')
  282.         if not not isFolder:
  283.             out.write(u'<div>\n            <span>')
  284.             out.write(escape(notDeleted.len()))
  285.             out.write(u'</span> \n            Items in this Channel Folder\n        </div>')
  286.         
  287.         out.write(u'\n    </a>')
  288.         out.seek(0)
  289.         return out
  290.  
  291.     handle_0.addUpdate('tmplcomp93734424', 'nextSibling', matchingItems, up_2_handle_0, u'matchingItems')
  292.     
  293.     def up_3_handle_0(viewName, view, tid):
  294.         out = StringIO()
  295.         out.write(u'<div id="')
  296.         out.write(quoteattr(tid))
  297.         out.write(u'">\n    ')
  298.         if not not showNewItems:
  299.             out.write(u'<div class="available-sort">\n        ')
  300.             out.write(fillStaticTemplate(u'sort-bar', onlyBody = True, section = 'main', itemSort = itemSort))
  301.             out.write(u'\n    </div>')
  302.         
  303.         out.write(u'\n</div>')
  304.         out.seek(0)
  305.         return out
  306.  
  307.     handle_0.addUpdate('tmplcomp79940247', 'nextSibling', matchingItems, up_3_handle_0, u'matchingItems')
  308.     
  309.     def up_4_handle_0(viewName, view, tid):
  310.         out = StringIO()
  311.         out.write(u'<div id="')
  312.         out.write(quoteattr(tid))
  313.         out.write(u'">  \n  ')
  314.         if not allItemsMode and not showNewItems or newItems.len() == matchingItems.len():
  315.             out.write(u'<div>\n      <a href="#" class="main-notification" onclick="return eventURL(\'action:toggleAllItemsMode\');">\n          ')
  316.             if not isFolder:
  317.                 out.write(u'<span><span>')
  318.                 out.write(escape(matchingItems.len() - newItems.len()))
  319.                 out.write(u'</span> more on this channel >></span>')
  320.             
  321.             out.write(u'\n          ')
  322.             if not not isFolder:
  323.                 out.write(u'<span><span>')
  324.                 out.write(escape(matchingItems.len()))
  325.                 out.write(u'</span> items in this channel folder >></span>')
  326.             
  327.             out.write(u'\n        </a>\n        <a href="#" class="main-notification-right" onclick="return eventURL(\'action:toggleAllItemsMode\');"> </a>\n     <br clear="left"></br>\n  </div>')
  328.         
  329.         out.write(u'\n</div>')
  330.         out.seek(0)
  331.         return out
  332.  
  333.     handle_0.addUpdate('tmplcomp06682742', 'nextSibling', matchingItems, up_4_handle_0, u'matchingItems')
  334.     
  335.     def up_5_handle_0(viewName, view, tid):
  336.         out = StringIO()
  337.         out.write(u'<div id="')
  338.         out.write(quoteattr(tid))
  339.         out.write(u'">\n        ')
  340.         if not len(allWatchableItems) == 0 and not isFolder and feed.getURL().startswith('dtv:directoryfeed'):
  341.             out.write(u'<a href="#" class="main-channelbar downloaded-channelbar" onclick="return eventURL(\'action:toggleWatchableView\')">\n            ')
  342.             if not showWatchableItems:
  343.                 out.write(u'<div class="triangle"></div>')
  344.             
  345.             out.write(u'\n            ')
  346.             if not not showWatchableItems:
  347.                 out.write(u'<div class="triangle down"></div>')
  348.             
  349.             out.write(u'\n            <span>')
  350.             tmplcomp42654771 = { }
  351.             tmplcomp22910251 = StringIO()
  352.             tmplcomp22910251.write(u'<span>')
  353.             tmplcomp22910251.write(escape(allWatchableItems.len()))
  354.             tmplcomp22910251.write(u'</span>')
  355.             tmplcomp22910251.seek(0)
  356.             tmplcomp42654771['len'] = tmplcomp22910251.read()
  357.             out.write(Template(_(u'${len} Downloaded')).substitute(tmplcomp42654771))
  358.             out.write(u'</span>\n        </a>')
  359.         
  360.         out.write(u'\n    </div>')
  361.         out.seek(0)
  362.         return out
  363.  
  364.     handle_0.addUpdate('tmplcomp32231030', 'nextSibling', allWatchableItems, up_5_handle_0, u'allWatchableItems')
  365.     
  366.     def up_6_handle_0(viewName, view, tid):
  367.         out = StringIO()
  368.         out.write(u'<div id="')
  369.         out.write(quoteattr(tid))
  370.         out.write(u'">\n        ')
  371.         if not len(watchableItems) == 0:
  372.             out.write(u'<div>\n            ')
  373.             out.write(fillStaticTemplate(u'sort-bar', onlyBody = True, section = 'watchable', itemSort = itemSortWatchable))
  374.             out.write(u'\n        </div>')
  375.         
  376.         out.write(u'\n    </div>')
  377.         out.seek(0)
  378.         return out
  379.  
  380.     handle_0.addUpdate('tmplcomp52501091', 'nextSibling', watchableItems, up_6_handle_0, u'watchableItems')
  381.     
  382.     def rep_7_handle_0(this, viewName, view, tid):
  383.         out = StringIO()
  384.         out.write(u'\n<div dragsourcetype="')
  385.         out.write(quoteattr(this.getDragType()))
  386.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  387.         out.write(quoteattr(this.getID()))
  388.         out.write(u'" dragicon="video-tnail-')
  389.         out.write(quoteattr(viewName + str(this.getID())))
  390.         out.write(u'" selectID="')
  391.         out.write(quoteattr(this.getID()))
  392.         out.write(u'" class="main-video draggable ')
  393.         out.write(quoteattr(this.getSelectedState(view)))
  394.         out.write(u' ')
  395.         out.write(quoteattr(this.getMoreInfoState()))
  396.         out.write(u'" dragsourcedata="itemlist-')
  397.         out.write(quoteattr(this.getID()))
  398.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  399.         out.write(quoteattr(urlencode(viewName)))
  400.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  401.         if not viewName == 'playlistView' or 'downloadeditem':
  402.             pass
  403.         out.write(quoteattr(''))
  404.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  405.         out.write(quoteattr(urlencode(viewName)))
  406.         out.write(u"', ")
  407.         out.write(quoteattr(urlencode(this.getID())))
  408.         out.write(u');" id="')
  409.         out.write(quoteattr(tid))
  410.         out.write(u'">\n    <div>')
  411.         out.write(this.getItemXML(viewName))
  412.         out.write(u'</div>\n</div>\n')
  413.         out.seek(0)
  414.         return out
  415.  
  416.     handle_0.addView('tmplcomp81136442', 'containerDiv', downloadingItems, rep_7_handle_0, u'downloadingItems')
  417.     
  418.     def rep_8_handle_0(this, viewName, view, tid):
  419.         out = StringIO()
  420.         out.write(u'\n<div dragsourcetype="')
  421.         out.write(quoteattr(this.getDragType()))
  422.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  423.         out.write(quoteattr(this.getID()))
  424.         out.write(u'" dragicon="video-tnail-')
  425.         out.write(quoteattr(viewName + str(this.getID())))
  426.         out.write(u'" selectID="')
  427.         out.write(quoteattr(this.getID()))
  428.         out.write(u'" class="main-video draggable ')
  429.         out.write(quoteattr(this.getSelectedState(view)))
  430.         out.write(u' ')
  431.         out.write(quoteattr(this.getMoreInfoState()))
  432.         out.write(u'" dragsourcedata="itemlist-')
  433.         out.write(quoteattr(this.getID()))
  434.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  435.         out.write(quoteattr(urlencode(viewName)))
  436.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  437.         if not viewName == 'playlistView' or 'downloadeditem':
  438.             pass
  439.         out.write(quoteattr(''))
  440.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  441.         out.write(quoteattr(urlencode(viewName)))
  442.         out.write(u"', ")
  443.         out.write(quoteattr(urlencode(this.getID())))
  444.         out.write(u');" id="')
  445.         out.write(quoteattr(tid))
  446.         out.write(u'">\n    <div>')
  447.         out.write(this.getItemXML(viewName))
  448.         out.write(u'</div>\n</div>\n')
  449.         out.seek(0)
  450.         return out
  451.  
  452.     handle_0.addView('tmplcomp99272360', 'containerDiv', newItems, rep_8_handle_0, u'newItems')
  453.     
  454.     def rep_9_handle_0(this, viewName, view, tid):
  455.         out = StringIO()
  456.         out.write(u'\n<div dragsourcetype="')
  457.         out.write(quoteattr(this.getDragType()))
  458.         out.write(u'" selectArea="itemlist" drageffectdownloadeditem="move" dragdestdata="playlistitem-')
  459.         out.write(quoteattr(this.getID()))
  460.         out.write(u'" dragicon="video-tnail-')
  461.         out.write(quoteattr(viewName + str(this.getID())))
  462.         out.write(u'" selectID="')
  463.         out.write(quoteattr(this.getID()))
  464.         out.write(u'" class="main-video draggable ')
  465.         out.write(quoteattr(this.getSelectedState(view)))
  466.         out.write(u' ')
  467.         out.write(quoteattr(this.getMoreInfoState()))
  468.         out.write(u'" dragsourcedata="itemlist-')
  469.         out.write(quoteattr(this.getID()))
  470.         out.write(u'" onclick="return handleSelect(event);" selectViewName="')
  471.         out.write(quoteattr(urlencode(viewName)))
  472.         out.write(u'" onmousedown="return handleContextMenuSelect(event);" dragdesttype="')
  473.         if not viewName == 'playlistView' or 'downloadeditem':
  474.             pass
  475.         out.write(quoteattr(''))
  476.         out.write(u'" ondblclick="return handleDblClick(event, \'')
  477.         out.write(quoteattr(urlencode(viewName)))
  478.         out.write(u"', ")
  479.         out.write(quoteattr(urlencode(this.getID())))
  480.         out.write(u');" id="')
  481.         out.write(quoteattr(tid))
  482.         out.write(u'">\n    <div>')
  483.         out.write(this.getItemXML(viewName))
  484.         out.write(u'</div>\n</div>\n')
  485.         out.seek(0)
  486.         return out
  487.  
  488.     handle_0.addView('tmplcomp60178836', 'containerDiv', watchableItems, rep_9_handle_0, u'watchableItems')
  489.     localvars = locals()
  490.     localvars.update(globals())
  491.     handle_0_0 = Handle(domHandler, localvars, onUnlink = (lambda : None))
  492.     handle_0.addSubHandle(handle_0_0)
  493.     localvars = locals()
  494.     localvars.update(globals())
  495.     handle_0_1 = Handle(domHandler, localvars, onUnlink = (lambda : None))
  496.     handle_0.addSubHandle(handle_0_1)
  497.     localvars = locals()
  498.     localvars.update(globals())
  499.     handle_0_2 = Handle(domHandler, localvars, onUnlink = (lambda : None))
  500.     handle_0.addSubHandle(handle_0_2)
  501.     handle.addSubHandle(handle_0)
  502.     out = StringIO()
  503.     out.write(u'<?xml version="1.0" encoding="utf-8"?>\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n')
  504.     out.write(u'<html dtvPlatform="')
  505.     out.write(quoteattr(urlencode(dtvPlatform)))
  506.     out.write(u'" eventCookie="')
  507.     out.write(quoteattr(urlencode(eventCookie)))
  508.     out.write(u'" xmlns="http://www.w3.org/1999/xhtml">\n\n<head>\n    <meta content="text/html; charset=utf-8" http-equiv="Content-Type"></meta>\n\n    <link href="')
  509.     out.write(quoteattr(resources.url(u'css/main.css')))
  510.     out.write(u'" type="text/css" rel="stylesheet"></link>\n    <script type="text/javascript">\n<!-- // Protect from our XML parser, which doesn\'t know to protect <script>\n\n///////////////////////////////////////////////////////////////////////////////\n//// For use on your page                                                  ////\n///////////////////////////////////////////////////////////////////////////////\n\nfunction getDTVPlatform() {\n    var elt = document.getElementsByTagName("html")[0];\n    return elt.getAttribute(\'dtvPlatform\');\n}\n\nfunction loadURL(url) {\n    try {\n        document.location.href = url;\n    } catch (e) {\n        // This may happen if the backend decides to handle the url load\n        // itself.\n    }\n}\n\n// For calling from page Javascript: Cause a URL to be loaded. The\n// assumption is that the application will notice, abort the load, and\n// take some action based on the URL.\nfunction eventURL(url) {\n    if (typeof(window.frontend) == \'undefined\') {\n\t// Generic strategy: trigger a load, and hope the application\n\t// catches it and cancels it without creating a race\n\t// condition.\n        loadURL(url)\n    } else {\n\t// OS X WebKit (KHTML) strategy: pass in an Objective C object\n\t// through the window object and call a method on it.\n\twindow.frontend.eventURL(url);\n    }\n\n    return false;\n}\n\n// Calls eventURL, then calls event.stopPropagation() and\n// event.preventDefault() so that the event chain is stopped.\nfunction eventURLAndStop(url, event) {\n  eventURL(url);\n  event.stopPropagation();\n  event.preventDefault();\n}\n\nfunction recommendItem(title, url) {\n    loadURL(\'http://www.videobomb.com/index/democracyemail?url=\' + \n            url + \'&title=\' + title);\n    return false;\n}\n\nfunction recommendChannel(title, url) {\n    // See also app.py if changing this URL\n    loadURL(\'http://www.videobomb.com/democracy_channel/email_friend\' +\n        \'?url=\' + url + \'&title=\' + title);\n    return false;\n}\n\n// Start the video player. The playlist will be the items in the view\n// named by viewName. If firstItemId is the id of an item in the view,\n// playback will start on that item; otherwise playback will start on\n// the first item.\nfunction playViewNamed(viewName, firstItemId) {\n    url = \'action:playViewNamed?\';\n    url = url + \'viewName=\' + URLencode(viewName);\n    url = url + \'&firstItemId=\' + URLencode(firstItemId);\n    eventURL(url);\n    return false;\n}\n\n// You can make \'incremental search\' text boxes on your page that\n// effectively tie the text box to the \'parameter\' argument of setViewFilter,\n// with the other argumens fixed. To do this, add these two attributes to\n// the text box:\n//   onfocus="startEditSearch(this)"\n//   onblur="endEditFilter()"\n// replacing the arguments in parentheses with the desired strings.\n//\n// You\'ll also need to provide a updateSearchString function at the\n// top of your template to perform the actual update\n\nvar editSearchField = null;\nvar editSearchOldValue = \'\';\nvar editSearchTimer = null;\nvar editSearchCallback = null;\n\nfunction onSearchFocus(obj){\n  if (obj.getAttribute(\'searching\') != \'1\') {\n\tobj.value="";\n\tobj.searching = \'1\';\n  }\n  startEditSearch(obj, null);\n}\n\nfunction startEditSearch(obj, callback) {\n  editSearchOldValue = obj.value;\n\n  editSearchField = obj;\n  editSearchCallback = callback;\n  editSearchTimerTick();\n}\n\nfunction editSearchUpdate() {\n    value = editSearchField.value;\n    if (editSearchOldValue != value) {\n\turl = \'action:setSearchString?searchString=\' + URLencode(value);\n\teventURL(url);\n\teditSearchOldValue = value;\n\tif(editSearchCallback) editSearchCallback();\n    }\n}\n\nfunction editSearchTimerTick() {\n    editSearchUpdate();\n    editSearchTimer = setTimeout(editSearchTimerTick, 50);\n}\n\nfunction endEditSearch() {\n  clearTimeout(editSearchTimer);\n  editSearchUpdate();\n}\n\n// Internal use: \'URL encode\' the given string.\nfunction URLencode(str) {\n    return encodeURIComponent(str)\n}\n\nfunction URLdecode(str) {\n  return decodeURIComponent(str)\n}\n\nvar currentSelectBoxMenu = null;\nfunction showSelectBoxMenu(id) {\n    document.getElementById(id).style.display = \'block\';\n    currentSelectBoxMenu = id;\n    document.addEventListener(\'click\', hideSelectBoxMenu, true)\n}\n\nfunction hideSelectBoxMenu(event) {\n    document.getElementById(currentSelectBoxMenu).style.display = \'\';\n    currentSelectBoxMenu = null;\n    document.removeEventListener(\'click\', hideSelectBoxMenu, true)\n}\n\n///////////////////////////////////////////////////////////////////////////////\n//// For calling by host templating code                                   ////\n///////////////////////////////////////////////////////////////////////////////\n\n// For calling by host templating code: Set CSS styles on the item\n// with the given ID to make it disappear.\nfunction hideItem(id) {\n    elt = document.getElementById(id);\n    elt.style.display = \'none\';\n    forceRedisplay(elt);\n}\n\n// For calling by host templating code: Set CSS styles on the item\n// with the given ID to make it visible if it was previously hidden.\nfunction showItem(id) {\n    elt = document.getElementById(id);\n    elt.style.display = \'\';\n    forceRedisplay(elt);\n}\n\n// For calling by host templating code: Replace the item with the\n// given id with the element described by the proided XML.\nfunction changeItem(id, newXML) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.parentNode.replaceChild(frag, elt);\n}\n\n// For calling by host templating code: Parse the XML in newXML into a\n// new element, and insert the new element immediately before the item\n// with the given id, such that the newly inserted item has the same\n// parent.\nfunction addItemBefore(newXML, id) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.parentNode.insertBefore(frag, elt);\n}    \n\n// For calling by host templating code: Parse the XML in newXML into a\n// new element, and insert the new element as the final child of the\n// item with the given id.\nfunction addItemAtEnd(newXML, id) {\n    elt = document.getElementById(id);\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.createContextualFragment(newXML);\n    elt.insertBefore(frag, null);\n}    \n\n// For calling by host templating code: Remove the item with the given\n// id.\nfunction removeItem(id) {\n    elt = document.getElementById(id);\n    elt.parentNode.removeChild(elt);\n}    \n\n// Internal use: Sometime if all you do is change the style on a node,\n// Safari doesn\'t update the view until your mouse is next over the\n// window. Force the issue by making a drastic change in the vicinity\n// of the given element and then reversing it.\nfunction forceRedisplay(elt) {\n    r = document.createRange();\n    r.selectNode(elt);\n    frag = r.extractContents();\n    r.insertNode(frag);\n}\n\nfunction handleContextMenuSelect(event) {\n  if(event.button == 2) {\n    var area = event.currentTarget.getAttribute("selectArea");\n    var id = event.currentTarget.getAttribute("selectID");\n    var viewName = event.currentTarget.getAttribute("selectViewName");\n    var url = \'action:handleContextMenuSelect?id=\' + id + \'&area=\' + area +\n              \'&viewName=\' + viewName;\n    eventURL(url);\n  }\n  return true;\n}\n\nfunction handleSelect(event) {\n   if(event.target.tagName && event.target.tagName.toUpperCase() == \'A\') {\n       // Either a link in the descrption, or a bomb/mailto/trash click\n       return true;\n    }\n    var id = event.currentTarget.getAttribute("selectID");\n    var viewName = event.currentTarget.getAttribute("selectViewName");\n    var area = event.currentTarget.getAttribute("selectArea");\n    var shiftKey = \'0\';\n    var ctrlKey = \'0\';\n    if(event.shiftKey) shiftKey = \'1\';\n    if(event.ctrlKey || event.metaKey) ctrlKey = \'1\';\n    eventURL(\'action:handleSelect?area=\' + area + \'&viewName=\' + viewName + \n\t\'&id=\' + id + \'&shiftDown=\' + shiftKey + \'&ctrlDown=\' + ctrlKey);\n    return true;\n}\n\nfunction handleDblClick(event, viewName, id) {\n   var target = event.target;\n   while (target != undefined && target.ondblclick === null && target.tagName.toUpperCase() != \'A\') {\n       target = target.parentNode;\n   }\n\n   if(target.tagName.toUpperCase() == \'A\') {\n       // Either a link in the descrption, or a bomb/mailto/trash click\n       return true;\n   } else {\n       return eventURL(\'action:playViewNamed?viewName=\' + viewName + \n           \'&firstItemId=\' + id);\n   }\n}\n\nfunction getKeyFromEvent(evt) {\n  var key = 0;\n  if (window.event)  {\n    key = evt.keyCode;\n  } else if (evt.which) {\n  \tkey = evt.which;\n  }\n\n  return key;\n}\n\nfunction sendKeyToSearchBox(event) {\n  if(event.altKey || event.ctrlKey || event.metaKey ||\n      (event.target.tagName && event.target.tagName.toUpperCase() == \'INPUT\'))\n      return true;\n  var key = getKeyFromEvent(event);\n  if ((key == 33) || (key == 34) || (key == 35) || (key == 36) || \n      (key == 37) || (key == 38) || (key == 39) || (key == 40))\n      return true;\n  var searchBox = document.getElementById("search-box");\n  searchBox.focus();\n  return true;\n}\n\nfunction playNewVideos(event, id) {\n  eventURL(\'action:playNewVideos?id=\' + id);\n  event.stopPropagation(); // don\'t want handleSelect to deal with this event\n  return false;\n}\n\n///////////////////////////////////////////////////////////////////////////////\n///////////////////////////////////////////////////////////////////////////////\n\n-->\n</script>\n\n    <script src="')
  511.     out.write(quoteattr(resources.url(u'templates/osxdnd.js')))
  512.     out.write(u'" type="text/javascript"></script>\n    \n    \n</head>\n\n<body dragdesttype="channel" drageffectchannel="move" dragdestdata="channelfolder-')
  513.     out.write(quoteattr(folder.getID()))
  514.     out.write(u'" onkeydown="sendKeyToSearchBox(event);"')
  515.     out.write(u' ' + bodyTagExtra)
  516.     out.write(u'>\n<div id="main-titlebar">\n    <img src="')
  517.     out.write(quoteattr(resources.url(u'images/folder-icon.png')))
  518.     out.write(u'" alt="" id="main-icon"></img>\n    ')
  519.     out.write(u'<span id="tmplcomp12122406"/>\n</div>\n<div id="main-container">\n    ')
  520.     out.write(u'\n\n')
  521.     out.write(u'<span id="tmplcomp02773866"/>\n\n    ')
  522.     out.write(u'<span id="tmplcomp36590227"/>\n    <div id="tmplcomp81136442">')
  523.     out.write(u'</div>\n\n\n\n\n\n<div class="available-channelbar-wrap">\n    ')
  524.     out.write(u'<span id="tmplcomp93734424"/>\n</div>\n\n')
  525.     out.write(u'<span id="tmplcomp79940247"/>\n\n<div id="tmplcomp99272360">')
  526.     out.write(u'</div>\n\n\n')
  527.     out.write(u'<span id="tmplcomp06682742"/>\n\n\n\n\n<div id="tmplcomp81821646"')
  528.     
  529.     _hideFunc = lambda : if not isFolder:
  530. passfeed.getURL().startswith('dtv:directoryfeed')
  531.     _dynHide = _hideFunc()
  532.     if _dynHide:
  533.         out.write(u' style="display:none">')
  534.     else:
  535.         out.write(u'>')
  536.     handle.addUpdateHideOnView('tmplcomp81821646', thisFeedView, _hideFunc, _dynHide)
  537.     out.write(u'\n    ')
  538.     out.write(u'<span id="tmplcomp32231030"/>\n    \n    ')
  539.     out.write(u'<span id="tmplcomp52501091"/>\n    <div id="tmplcomp60178836">')
  540.     out.write(u'</div>\n</div>\n\n\n')
  541.     out.write(u'\n</div>\n')
  542.     out.write(u'<span id="tmplcomp05112787"/>\n</body>\n</html>')
  543.     out.seek(0)
  544.     return (out, handle)
  545.  
  546.